﻿namespace KeRui.TemplateMaker
{
    using KeRui.BLL;
    using KeRui.Common;
    using KeRui.DAL;
    using KeRui.Model;
    using iPortal.TemplateEngine;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Text;
    using System.Text.RegularExpressions;

    public class ResolveTag
    {
        private static TemplateDocument _CompressHtml(TemplateDocument templateDocument)
        {
            Regex regex = new Regex(@"\n\s*", RegexOptions.Compiled);
            Regex regex2 = new Regex(@"\n\s*\r", RegexOptions.Compiled);
            Regex regex3 = new Regex("( )+", RegexOptions.Compiled);
            string renderText = templateDocument.GetRenderText();
            renderText = regex.Replace(renderText, string.Empty);
            renderText = regex2.Replace(renderText, string.Empty);
            return new TemplateDocument(regex3.Replace(renderText, " "));
        }

        private static void _ResolveForeach(TemplateDocument document)
        {
            ResolveAttribute attribute = new ResolveAttribute();
            TagData data = new TagData();
            ElementCollection<Tag> childTagsByTagName = document.GetChildTagsByTagName("foreach");
            foreach (Tag tag in childTagsByTagName)
            {
                string nodeTag = tag.Attributes.GetValue("from");
                if (nodeTag.Contains("node"))
                {
                    NodeAttribute resolveAttribute = attribute.ResolveNodeAttribute(nodeTag);
                    document.Variables.SetValue(nodeTag, data.DataForNodeID(resolveAttribute));
                    tag.BeforeRender += new CancelEventHandler(ResolveTag.Tag_BeforeRender);
                }
                if (nodeTag.StartsWith("parameter_"))
                {
                    document.Variables.SetValue(nodeTag, data.DataForParameter(nodeTag));
                    tag.BeforeRender += new CancelEventHandler(ResolveTag.Tag_BeforeRender);
                }
            }
        }

        private static void _ResolveLocation(TemplateDocument templateDocument, int nodeID, int pageIndex)
        {
            string str;
            int num;
            KeRui.BLL.CmsNode node = new KeRui.BLL.CmsNode();
            if (string.IsNullOrEmpty(node.GetModelByCache(nodeID).ParentPath))
            {
                str = nodeID.ToString();
            }
            else
            {
                str = node.GetModelByCache(nodeID).ParentPath + "," + nodeID;
            }
            StringBuilder builder = new StringBuilder();
            KeRui.BLL.CmsSite site = new KeRui.BLL.CmsSite();
            string siteUrl = site.GetModelByCache(node.GetModelByCache(nodeID).SiteID).SiteUrl;
            string[] strArray = str.Split(",".ToCharArray());
            for (num = 0; num < strArray.Length; num++)
            {
                KeRui.Model.CmsNode modelByCache;
                builder.Append("<li>");
                if (num != (strArray.Length - 1))
                {
                    modelByCache = node.GetModelByCache(Convert.ToInt32(strArray[num]));
                    builder.AppendFormat("<a class='c327CB6' href=\"{0}\">{1}</a>>>", siteUrl + "/" + modelByCache.NodePath, modelByCache.NodeName);
                }
                else
                {
                    modelByCache = node.GetModelByCache(Convert.ToInt32(strArray[num]));
                    builder.AppendFormat("<a class='c327CB6' href=\"{0}\">{1}</a>", siteUrl + "/" + modelByCache.NodePath, modelByCache.NodeName);
                }
                builder.Append("</li>");
            }
            builder.Append("</li>");
            templateDocument.Variables.SetExpValue("list.location", builder.ToString());
            templateDocument.Variables.SetExpValue("list.currentlocation", node.GetModelByCache(nodeID).NodeName);
            templateDocument.Variables.SetExpValue("list.nodeid", nodeID);
            string arrChildID = node.GetModelByCache(nodeID).arrChildID;
            if (!(arrChildID != string.Empty))
            {
                return;
            }
            StringBuilder builder2 = new StringBuilder();
            builder2.AppendFormat("<li class=\"fB\">{0}的其他栏目：</li>", node.GetModelByCache(nodeID).NodeName);
            num = 0;
        Label_027C:;
            if (num < arrChildID.Split(new char[] { ',' }).Length)
            {
                int num2 = Convert.ToInt16(arrChildID.Split(new char[] { ',' })[num]);
                KeRui.Model.CmsNode node3 = node.GetModelByCache(num2);
                if (num != (arrChildID.Split(new char[] { ',' }).Length - 1))
                {
                    builder2.AppendFormat("<li><a href=\"/{0}\">{1}</a><span>|</span></li>", node3.NodePath, node3.NodeName);
                }
                else
                {
                    builder2.AppendFormat("<li><a href=\"/{0}\">{1}</a></li>", node3.NodePath, node3.NodeName);
                }
                num++;
                goto Label_027C;
            }
            templateDocument.Variables.SetExpValue("list.childnav", builder2.ToString());
        }

        private static void _ResolveNodeListData(TemplateDocument templateDocument, int nodeID, int pageIndex, int pageSize)
        {
            int num3;
            int num6;
            Tag childTagById = templateDocument.GetChildTagById("datalist");
            KeRui.BLL.CmsNode node = new KeRui.BLL.CmsNode();
            if (pageSize == 0)
            {
                pageSize = 0x19;
            }
            KeRui.Model.CmsNode modelByCache = node.GetModelByCache(nodeID);
            templateDocument.Variables.SetValue("node", modelByCache);
            int num = pageIndex * pageSize;
            int num2 = ((pageIndex - 1) * pageSize) + 1;
            string range = string.Format("WHERE cc.rowscount BETWEEN {0} AND {1}", num2, num);
            DataTable table = TagData.DataForNodeDetails(nodeID, 0, "", range, "", true);
            if (table != null)
            {
                table.Columns.Add("PostDate", typeof(string));
                table.Columns.Add("ImageCount", typeof(int));
                for (num3 = 0; num3 < table.Rows.Count; num3++)
                {
                    table.Rows[num3]["rowscount"] = num3 + 1;
                    table.Rows[num3]["PostDate"] = Utils.GetDateTime(table.Rows[num3]["UpdateTime"].ToString());
                    string[] strArray = Utils.SplitString(table.Rows[num3]["Content"].ToString(), "<img ");
                    if (strArray.Length > 0)
                    {
                        table.Rows[num3]["ImageCount"] = strArray.Length - 1;
                    }
                    else
                    {
                        table.Rows[num3]["ImageCount"] = 0;
                    }
                }
                templateDocument.Variables.SetValue("nodelistdata", table);
            }
            if (childTagById != null)
            {
                childTagById.BeforeRender += new CancelEventHandler(ResolveTag.Tag_BeforeRender);
            }
            KeRui.BLL.CmsSite site = new KeRui.BLL.CmsSite();
            KeRui.BLL.CmsContent content = new KeRui.BLL.CmsContent();
            string str2 = site.GetModelByCache(node.GetModelByCache(nodeID).SiteID).SiteUrl + "/" + node.GetModelByCache(nodeID).NodePath + "/";
            int contentCount = node.GetModelByCache(nodeID).ContentCount;
            if ((contentCount % pageSize) == 0)
            {
                num6 = contentCount / pageSize;
            }
            else
            {
                num6 = (contentCount / pageSize) + 1;
            }
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat("<div class=\"page\"><span><strong>共{0}页</strong></span>", num6);
            for (num3 = 1; num3 < (num6 + 1); num3++)
            {
                if (num3 == 1)
                {
                    builder.AppendFormat("<a {1} href=\"{0}\">1</a>", str2 + "Index.shtml", (num3 == pageIndex) ? "class='current'" : "");
                }
                if (((num3 >= (pageIndex - 2)) && (num3 <= (pageIndex + 2))) && ((num3 != 1) && (num3 != num6)))
                {
                    if (num3 == (pageIndex - 2))
                    {
                        builder.AppendFormat("...<a {1} href=\"{0}\">{2}</a>", string.Concat(new object[] { str2, "p", num3, ".shtml" }), (num3 == pageIndex) ? "class='current'" : "", num3);
                    }
                    else if (num3 == (pageIndex + 2))
                    {
                        builder.AppendFormat("<a {1} href=\"{0}\">{2}</a>...", string.Concat(new object[] { str2, "p", num3, ".shtml" }), (num3 == pageIndex) ? "class='current'" : "", num3);
                    }
                    else
                    {
                        builder.AppendFormat("<a {1} href=\"{0}\">{2}</a>", string.Concat(new object[] { str2, "p", num3, ".shtml" }), (num3 == pageIndex) ? "class='current'" : "", num3);
                    }
                }
            }
            builder.AppendFormat("<a {1} href=\"{0}\">{2}</a></li>", string.Concat(new object[] { str2, "p", num6, ".shtml" }), (num6 == pageIndex) ? "class='current'" : "", num6);
            if (pageIndex == num6)
            {
                builder.AppendFormat("<a href=\"{0}\">下一页</a>", string.Concat(new object[] { str2, "p", num6, ".shtml" }));
            }
            else
            {
                builder.AppendFormat("<a href=\"{0}\">下一页</a>", string.Concat(new object[] { str2, "p", pageIndex + 1, ".shtml" }));
            }
            builder.AppendFormat("<a href=\"{0}\">尾页</a>", string.Concat(new object[] { str2, "p", num6, ".shtml" }));
            builder.Append("</div>");
            if (num6 == 1)
            {
                builder = new StringBuilder();
            }
            templateDocument.Variables.SetValue("page", builder.ToString());
            ElementCollection<Template> childTemplatesByName = templateDocument.GetChildTemplatesByName("template");
            if (childTemplatesByName != null)
            {
                foreach (Template template in childTemplatesByName)
                {
                    DataTable table2 = content.GetCmsContentDetailsByParentNodeID(nodeID, "TOP 3", " AND CONTENTTYPE=1 ", "");
                    template.Variables.SetValue("headline", table2);
                }
            }
        }

        private static void _ResolveNodeListData(TemplateDocument templateDocument, int nodeID, string strWhere, int pageIndex, int pageSize)
        {
            Tag childTagById = templateDocument.GetChildTagById("newslist");
            int num = pageIndex * 0x19;
            int num2 = ((pageIndex - 1) * 0x19) + 1;
            string range = string.Format("WHERE cc.rowscount BETWEEN {0} AND {1}", num2, num);
            DataTable table = TagData.DataForNodeDetails(nodeID, pageSize, strWhere, range, "", false);
            if (table != null)
            {
                table.Columns.Add("PostDate", typeof(string));
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    table.Rows[i]["rowscount"] = i + 1;
                    table.Rows[i]["PostDate"] = Utils.GetDateTime(table.Rows[i]["UpdateTime"].ToString());
                }
                templateDocument.Variables.SetValue("nodelistdata", table);
            }
            if (childTagById != null)
            {
                childTagById.BeforeRender += new CancelEventHandler(ResolveTag.Tag_BeforeRender);
            }
        }

        private static void _ResolveNodeListData2(TemplateDocument templateDocument, int nodeID, int pageIndex, int pageSize)
        {
            int num3;
            int num6;
            Tag childTagById = templateDocument.GetChildTagById("datalist");
            KeRui.BLL.CmsNode node = new KeRui.BLL.CmsNode();
            KeRui.Model.CmsNode modelByCache = node.GetModelByCache(nodeID);
            if (pageSize == 0)
            {
                pageSize = 0x19;
            }
            templateDocument.Variables.SetValue("node", modelByCache);
            int num = pageIndex * pageSize;
            int num2 = ((pageIndex - 1) * pageSize) + 1;
            string range = string.Format("WHERE cc.rowscount BETWEEN {0} AND {1}", num2, num);
            DataTable table = TagData.DataForNodeDetails2(nodeID, 0, "", range, "", true);
            if (table != null)
            {
                table.Columns.Add("PostDate", typeof(string));
                for (num3 = 0; num3 < table.Rows.Count; num3++)
                {
                    table.Rows[num3]["rowscount"] = num3 + 1;
                    table.Rows[num3]["PostDate"] = Utils.GetDateTime(table.Rows[num3]["UpdateTime"].ToString());
                }
                templateDocument.Variables.SetValue("nodelistdata", table);
            }
            if (childTagById != null)
            {
                childTagById.BeforeRender += new CancelEventHandler(ResolveTag.Tag_BeforeRender);
            }
            KeRui.BLL.CmsContent content = new KeRui.BLL.CmsContent();
            KeRui.BLL.CmsSite site = new KeRui.BLL.CmsSite();
            string str2 = site.GetModelByCache(node.GetModelByCache(nodeID).SiteID).SiteUrl + "/" + node.GetModelByCache(nodeID).NodePath + "/";
            int contentCount = node.GetModelByCache(nodeID).ContentCount;
            int num5 = contentCount;
            if ((num5 % pageSize) == 0)
            {
                num6 = num5 / pageSize;
            }
            else
            {
                num6 = (num5 / pageSize) + 1;
            }
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat("<div class=\"page\"><span><strong>共{0}页</strong></span>", num6);
            for (num3 = 1; num3 < (num6 + 1); num3++)
            {
                if (num3 == 1)
                {
                    builder.AppendFormat("<a {1} href=\"{0}\">1</a>", str2 + "Index.shtml", (num3 == pageIndex) ? "class='current'" : "");
                }
                if (((num3 >= (pageIndex - 2)) && (num3 <= (pageIndex + 2))) && ((num3 != 1) && (num3 != num6)))
                {
                    if (num3 == (pageIndex - 2))
                    {
                        builder.AppendFormat("...<a {1} href=\"{0}\">{2}</a>", string.Concat(new object[] { str2, "p", num3, ".shtml" }), (num3 == pageIndex) ? "class='current'" : "", num3);
                    }
                    else if (num3 == (pageIndex + 2))
                    {
                        builder.AppendFormat("<a {1} href=\"{0}\">{2}</a>...", string.Concat(new object[] { str2, "p", num3, ".shtml" }), (num3 == pageIndex) ? "class='current'" : "", num3);
                    }
                    else
                    {
                        builder.AppendFormat("<a {1} href=\"{0}\">{2}</a>", string.Concat(new object[] { str2, "p", num3, ".shtml" }), (num3 == pageIndex) ? "class='current'" : "", num3);
                    }
                }
            }
            builder.AppendFormat("<a {1} href=\"{0}\">{2}</a></li>", string.Concat(new object[] { str2, "p", num6, ".shtml" }), (num6 == pageIndex) ? "class='current'" : "", num6);
            if (pageIndex == num6)
            {
                builder.AppendFormat("<a href=\"{0}\">下一页</a>", string.Concat(new object[] { str2, "p", num6, ".shtml" }));
            }
            else
            {
                builder.AppendFormat("<a href=\"{0}\">下一页</a>", string.Concat(new object[] { str2, "p", pageIndex + 1, ".shtml" }));
            }
            builder.AppendFormat("<a href=\"{0}\">尾页</a>", string.Concat(new object[] { str2, "p", num6, ".shtml" }));
            builder.Append("</div>");
            if (num6 == 1)
            {
                builder = new StringBuilder();
            }
            templateDocument.Variables.SetValue("page", builder.ToString());
            ElementCollection<Template> childTemplatesByName = templateDocument.GetChildTemplatesByName("template");
            if (childTemplatesByName != null)
            {
                foreach (Template template in childTemplatesByName)
                {
                    DataTable table2 = content.GetCmsContentDetailsByParentNodeID(nodeID, "TOP 3", " AND CONTENTTYPE=1 ", "");
                    template.Variables.SetValue("headline", table2);
                }
            }
        }

        private static TemplateDocument _ResolveNodePage(TemplateDocument templateDocument, int nodeID)
        {
            string renderText = templateDocument.GetRenderText();
            Match match = new Regex("(?<nodepage><nodepage\\s+type=\"(?<type>\\w+)\"/>)").Match(renderText);
            if (match.Success)
            {
                renderText = renderText.Replace(match.Groups["nodepage"].ToString(), string.Format("<!--#include file=\"/NodeSingalPage/Node_{0}_{1}.shtml\"-->", nodeID, match.Groups["type"]));
            }
            return new TemplateDocument(renderText);
        }

        private static void _ResolveTab(TemplateDocument templateDocument, int nodeID, string selectedValues, string postUrl)
        {
            KeRui.BLL.CmsNode node = new KeRui.BLL.CmsNode();
            int modelID = node.GetModelByCache(nodeID).ModelID;
            List<KeRui.Model.CmsField> list = new KeRui.BLL.CmsField().GetList("ModelID=" + modelID + " AND IsTab=1");
            string[] strArray = selectedValues.Split(new char[] { ',' });
            StringBuilder builder = new StringBuilder();
            foreach (KeRui.Model.CmsField field2 in list)
            {
                builder.Append("<ul>");
                string[] strArray2 = BuildAttrValue(field2.StyleValue).Split(new char[] { ',' });
                for (int i = 0; i < strArray2.Length; i++)
                {
                    if (i != 0)
                    {
                        if (!CheckAttributeIDInClass(selectedValues, strArray2[i]))
                        {
                            builder.AppendFormat("<li class=\"c0062E4\"><A href=\"{0}\">{1}</A></li>", string.Concat(new object[] { "/aspx/InfoList.aspx?nodeid=", nodeID, "&", field2.FieldName, "=", strArray2[i], "&FieldAttr=", GetFieldAttrValue(field2.StyleValue, strArray2[i]), postUrl }), strArray2[i]);
                        }
                        else
                        {
                            builder.AppendFormat("<li class=\"col03thover\"><A href=\"{0}\">{1}</A></li>", string.Concat(new object[] { "/aspx/InfoList.aspx?nodeid=", nodeID, "&", field2.FieldName, "=", strArray2[i], "&FieldAttr=", GetFieldAttrValue(field2.StyleValue, strArray2[i]), postUrl }), strArray2[i]);
                        }
                    }
                    else if (CheckAttributeIDInClass(selectedValues, strArray2[i]) || string.IsNullOrEmpty(selectedValues))
                    {
                        builder.AppendFormat("<li class=\"col03thover\"><A href=\"{0}\">{1}</A></li>", "/" + node.GetModelByCache(nodeID).NodePath, strArray2[i]);
                    }
                    else
                    {
                        builder.AppendFormat("<li class=\"c0062E4\"><A href=\"{0}\">{1}</A></li>", "/" + node.GetModelByCache(nodeID).NodePath, strArray2[i]);
                    }
                }
                builder.Append("</ul>");
            }
            templateDocument.SetExpValue("list.tab", builder.ToString());
        }

        private static void _ResolveTemplate(TemplateDocument document)
        {
            TagData data = new TagData();
            ElementCollection<Template> childTemplatesByName = document.GetChildTemplatesByName("template");
            foreach (Template template in childTemplatesByName)
            {
                ResolveAttribute attribute = new ResolveAttribute();
                ElementCollection<Tag> childTagsByTagName = template.GetChildTagsByTagName("foreach");
                foreach (Tag tag in childTagsByTagName)
                {
                    string str = tag.Attributes.GetValue("from");
                    if (str.Contains("node"))
                    {
                        NodeAttribute resolveAttribute = attribute.ResolveNodeAttribute(str.Replace("#.", string.Empty));
                        template.Variables.SetValue(str.Replace("#.", string.Empty), data.DataForNodeID(resolveAttribute));
                        tag.BeforeRender += new CancelEventHandler(ResolveTag.Tag_BeforeRender);
                    }
                    if (str.Contains("parameter_"))
                    {
                        template.Variables.SetValue(str.Replace("#.", string.Empty), data.DataForParameter(str.Replace("#.", string.Empty)));
                    }
                    tag.BeforeRender += new CancelEventHandler(ResolveTag.Tag_BeforeRender);
                }
            }
        }

        private static void _ResolveVocation(TemplateDocument document)
        {
            ResolveAttribute attribute = new ResolveAttribute();
            TagData data = new TagData();
            ElementCollection<Tag> childTagsByTagName = document.GetChildTagsByTagName("foreach");
            foreach (Tag tag in childTagsByTagName)
            {
                string nodeTag = tag.Attributes.GetValue("from");
                if (nodeTag.Contains("vocation"))
                {
                    SellerVocationAttribute resolveAttribute = attribute.ResolveSellerVocationAttribute(nodeTag);
                    document.Variables.SetValue(nodeTag, data.DataForVocationID(resolveAttribute));
                    tag.BeforeRender += new CancelEventHandler(ResolveTag.Tag_BeforeRenderSellerUrl);
                }
                if (nodeTag.Contains("node"))
                {
                    NodeAttribute attribute3 = attribute.ResolveNodeAttribute(nodeTag);
                    document.Variables.SetValue(nodeTag, data.DataForNodeID(attribute3));
                    tag.BeforeRender += new CancelEventHandler(ResolveTag.Tag_BeforeRender);
                }
                if (nodeTag.StartsWith("parameter_"))
                {
                    document.Variables.SetValue(nodeTag, data.DataForParameter(nodeTag));
                    tag.BeforeRender += new CancelEventHandler(ResolveTag.Tag_BeforeRender);
                }
            }
        }

        private static string BuildAttrValue(string className)
        {
            StringBuilder builder = new StringBuilder();
            List<KeRui.Model.CmsFieldAttr> list = new KeRui.BLL.CmsFieldAttr().GetList("ClassName='" + className + "'");
            for (int i = 0; i < list.Count; i++)
            {
                if (i != (list.Count - 1))
                {
                    builder.AppendFormat("{0},", list[i].AttributeName);
                }
                else
                {
                    builder.AppendFormat("{0}", list[i].AttributeName);
                }
            }
            return builder.ToString();
        }

        private static bool CheckAttributeIDInClass(string attributeIDs, string attributeName)
        {
            if (!string.IsNullOrEmpty(attributeIDs))
            {
                foreach (string str in attributeIDs.Split(new char[] { ',' }))
                {
                    if (GetFieldAttrValues().Select("AttributeID=" + str + " AND AttributeName='" + attributeName + "'").Length > 0)
                    {
                        return true;
                    }
                }
            }
            return false;
        }

        public static TemplateDocument CompressHtml(TemplateDocument templateDocument)
        {
            return _CompressHtml(templateDocument);
        }

        private static string GetFieldAttrValue(string className, string attributeName)
        {
            return GetFieldAttrValues().Select("ClassName='" + className + "' AND AttributeName='" + attributeName + "'")[0]["AttributeID"].ToString();
        }

        private static DataTable GetFieldAttrValues()
        {
            object cache = DataCache.GetCache("GetFieldAttrValues");
            if (cache == null)
            {
                try
                {
                    KeRui.DAL.Common common = new KeRui.DAL.Common();
                    cache = common.GetList("CmsFieldAttr", -1, -1, "", "AttributeID ASC").Tables[0];
                    if (cache != null)
                    {
                        int configInt = ConfigHelper.GetConfigInt("DataCache");
                        DataCache.SetCache("GetFieldAttrValues", cache, DateTime.Now.AddMinutes((double) configInt), TimeSpan.Zero);
                    }
                }
                catch
                {
                }
            }
            return (DataTable) cache;
        }

        private static string GetItemUrlValue(int contentID, int nodeID)
        {
            string str;
            KeRui.Model.CmsNode modelByCache;
            KeRui.BLL.CmsNode node = new KeRui.BLL.CmsNode();
            KeRui.BLL.CmsSite site = new KeRui.BLL.CmsSite();
            if (nodeID != 0)
            {
                modelByCache = node.GetModelByCache(nodeID);
                str = site.GetModelByCache(modelByCache.SiteID).SiteUrl + "/" + modelByCache.NodePath + "/";
            }
            else
            {
                KeRui.BLL.CmsContent content = new KeRui.BLL.CmsContent();
                modelByCache = node.GetModelByCache(content.GetModel(contentID).NodeID);
                str = site.GetModelByCache(modelByCache.SiteID).SiteUrl + "/" + modelByCache.NodePath + "/";
            }
            return (str + contentID + ".shtml");
        }

        private static string GetSellerUrlValue(int sellerid)
        {
            string str = "http://ywt.88bx.com/wshy/Seller/index/";
            if (sellerid != 0)
            {
                return (str + sellerid);
            }
            return str;
        }

        public static void ResolveForeach(TemplateDocument templateDocument)
        {
            _ResolveForeach(templateDocument);
        }

        public static void ResolveLocation(TemplateDocument templateDocument, int nodeID, int pageIndex)
        {
            _ResolveLocation(templateDocument, nodeID, pageIndex);
        }

        public static void ResolveNodeListData(TemplateDocument templateDocument, int nodeID, int pageIndex, int pageSize)
        {
            _ResolveNodeListData(templateDocument, nodeID, pageIndex, pageSize);
        }

        public static void ResolveNodeListData(TemplateDocument templateDocument, int nodeID, string strWhere, int pageIndex, int pageSize)
        {
            _ResolveNodeListData(templateDocument, nodeID, strWhere, pageIndex, pageSize);
        }

        public static void ResolveNodeListData2(TemplateDocument templateDocument, int nodeID, int pageIndex, int pageSize)
        {
            _ResolveNodeListData2(templateDocument, nodeID, pageIndex, pageSize);
        }

        public static TemplateDocument ResolveNodePage(TemplateDocument templateDocument, int nodeID)
        {
            return _ResolveNodePage(templateDocument, nodeID);
        }

        public static void ResolveTab(TemplateDocument templateDocument, int nodeID, string selectedValue, string postUrl)
        {
            _ResolveTab(templateDocument, nodeID, selectedValue, postUrl);
        }

        public static void ResolveTemplate(TemplateDocument document)
        {
            _ResolveTemplate(document);
        }

        public static void ResolveVocation(TemplateDocument templateDocument)
        {
            _ResolveVocation(templateDocument);
        }

        private static void Tag_BeforeRender(object sender, CancelEventArgs e)
        {
            ForEachTag tag = (ForEachTag) sender;
            DataRowView view = (DataRowView) tag.Item.Value;
            if (view.Row.Table.Columns.Contains("NodeID") && view.Row.Table.Columns.Contains("ContentID"))
            {
                tag.Item.SetExpValue("url", GetItemUrlValue(Convert.ToInt32(view["ContentID"]), Convert.ToInt32(view["NodeID"])));
            }
            else if (view.Row.Table.Columns.Contains("ContentID"))
            {
                tag.Item.SetExpValue("url", GetItemUrlValue(Convert.ToInt32(view["ContentID"]), 0));
            }
        }

        private static void Tag_BeforeRenderSellerUrl(object sender, CancelEventArgs e)
        {
            ForEachTag tag = (ForEachTag) sender;
            DataRowView view = (DataRowView) tag.Item.Value;
            if (view.Row.Table.Columns.Contains("SellerId"))
            {
                tag.Item.SetExpValue("url", GetSellerUrlValue(Convert.ToInt32(view["SellerId"])));
            }
            else if (view.Row.Table.Columns.Contains("ContentID"))
            {
            }
        }
    }
}

